import React, { useState, useEffect, useCallback } from 'react';
import { connect } from 'dva';
import { Tabs, Tree, Spin, Button } from 'antd';
import { CaretDownOutlined } from '@ant-design/icons';
import CanvasContainer from './CanvasContainer';
import style from '@/pages/IndexPage.css';
function CanvasManager({ dispatch, user, board  }){
    const { authorized } = user;
    const { canvasBoard } = board;
    useEffect(()=>{
        // 节点切换为区域树下的根节点
        if ( authorized ) {
            dispatch({ type:'board/fetchCanvasBoard'});
            // dispatch({ type:'board/setCanvasBoard', payload:{ result:JSON.stringify([]) }});
        }
    },[authorized])
    const onDispatch = useCallback((action)=>{
        dispatch(action);
    },[]);
    return (
        <CanvasContainer data={canvasBoard} onDispatch={onDispatch} />
         
    )
}

export default connect(({ user, board })=>({ user, board }))(CanvasManager);